<script>
var vida;
vida = function() {
    Date.prototype.pattern = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12,
            "H+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            S: this.getMilliseconds()
        };
        var week = {
            "0": "/u65e5",
            "1": "/u4e00",
            "2": "/u4e8c",
            "3": "/u4e09",
            "4": "/u56db",
            "5": "/u4e94",
            "6": "/u516d"
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
        }
        if (/(E+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""])
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
            }
        }
        return fmt
    };
    var modcont = [];
    var accData = $("#accdata").val();
    accData = eval("(" + accData + ")");
    var modcont1 = '<table border="0" cellspacing="0" cellpadding="0" class="lc-tj ft-l">';
    modcont1 += '<tr><td rowspan="2" class="tit">投资</td><td class="money1" valign="bottom">¥' + '<?php echo number_format($user_result['sum_result']['current_principal_money'],2);?>' + "</td></tr>";
    modcont1 += '<tr><td class="ds" valign="top">¥' + '<?php echo number_format($user_result['wait_result']['current_principal_money'],2);?>' + '[待收本金]</td></tr><tr><td  rowspan="2" class="tit">收益</td><td class="money2"  valign="bottom">¥' + '<?php echo number_format($user_result['sum_result']['current_interest_money'],2);?>'   + "</td></tr>";
    modcont1 += '<tr><td class="ds" " valign="top">¥' + '<?php echo number_format($user_result['wait_result']['current_interest_money'],2);?>' + "[待收收益]</td></tr></table>";
    modcont1 += '<table class="lc-tjr"><tr><td ><span class="jqsyl-t">收益率</span><span class="jqsyl-l"><?php if($user_account->getInvestment() == 0):?><?php echo round(0,2)?><?php else:?><?php echo round($user_account->getInterest()/$user_account->getInvestment(),2)?><?php endif;?>
%</span></td></td></table>';
    modcont.push(modcont1);
    var modcont2 = '<dl class="wdjk">';
    modcont2 += '<dd class="top"><span class="tit top">借款金额</span><span class="zje">¥' + '<?php echo number_format($user_account->getLoanSuccessMoney(),2)?>' + "</span></dd>";
    modcont2 += '<dd><span class="tit">待还总金额</span><span >¥' + '<?php echo number_format($user_result['wait_pay']['current_money'],2);?>' + "</span></dd>";
    <?php $wait_time = $user_result['wait_pay']['current_end_time']?date("Y-m-d",  strtotime($user_result['wait_pay']['current_end_time'])):'暂无借款';?>
    modcont2 += '<dd><span class="tit">预期还款时间</span><span>' + '<?php echo $wait_time;?>' + "</span></dd>";
    modcont2 += '<dd><span class="tit">近30天应还款金额</span><span class="col">¥' + '<?php echo number_format($user_result['wait_lasted_pay']['current_money'],2);?>' + "</span></dd>";
    modcont2 += '<dd><span class="tit">冻结资金</span><span >¥' + '<?php echo number_format($user_account->getBlockedMoney(),2)?>' + "</span></dd></dl>";
    modcont.push(modcont2);
    var modcont3 = ' <table class="tbgk table" border="0" cellspacing="0" cellpadding="0">';
    modcont3 += ' <thead><tr><th width="30%">状态</th><th width="40%">笔数</th><th width="30%">金额</th></tr></thead>';
    modcont3 += ' <tr><td><a href="/account/backlend">回款中</a></td><td>' + '<?php  if(!$user_result["repaymenting"]["count"]){echo "0";}else{echo $user_result["repaymenting"]["count"]; }?>' + "</td><td>¥" + '<?php echo number_format($user_result["repaymenting"]["current_money"],2);?>' + "</td></tr>";
    modcont3 += '<tr><td><a href="/account/inbids">投标中</a></td><td>' + <?php echo $user_result['loaning']->getCount();?> + "</td><td>¥" + '<?php echo number_format($user_result['loaning']->getLoanMoney(),2);?>' + "</td></tr>";
    modcont3 += '<tr><td><a href="/account/returnedend">已回款</a></td><td>' + '<?php echo $user_result["already_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["already_repaymenting"]["current_money"],2);?>' + "</td></tr>";
    modcont3 += "<tr><td>总计</td><td>" + '<?php echo $user_result["repaymenting"]["count"]+$user_result['loaning']->getCount()+$user_result["already_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["repaymenting"]["current_money"]+$user_result['loaning']->getLoanMoney()+$user_result["already_repaymenting"]["current_money"],2);?>' + "</td></tr></table>";
    modcont.push(modcont3);
    var modcont4 = '<dl class="rzxx">';
    modcont4 += '<dd><span class="tit">信用总额度</span><span>¥' + '<?php echo number_format($user_account->getQuota(),2)?>' + '</span></dd>';
    modcont4 += '<dd><span class="tit">可使用额度</span><span class="col">¥' + '<?php echo number_format($user_account->getSurplusQuota(),2)?>' + '</span></dd></dl>';
    modcont.push(modcont4);
    var modcont5 = '<table class="tbgk table" border="0" cellspacing="0" cellpadding="0">';
    modcont5 += '<thead><tr><th width="30%">状态</th><th width="40%">笔数</th><th width="30%">金额</th></tr></thead>';
    modcont5 += "<tr><td>本月</td><td>" + '<?php echo $user_result["td_month_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["td_month_repaymenting"]["current_money"],2);?>' + "</td></tr>";
    modcont5 += "<tr><td>下月</td><td>" + '<?php echo $user_result["next_month_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["next_month_repaymenting"]["current_money"],2);?>' + "</td></tr>";
    modcont5 += "<tr><td>本年</td><td>" + '<?php echo $user_result["td_year_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["td_year_repaymenting"]["current_money"],2);?>' + "</td></tr>";
    modcont5 += "<tr><td>总计</td><td>" + '<?php echo $user_result["td_month_repaymenting"]["count"]+$user_result["next_month_repaymenting"]["count"]+$user_result["td_year_repaymenting"]["count"];?>' + "</td><td>¥" + '<?php echo number_format($user_result["td_month_repaymenting"]["current_money"]+$user_result["next_month_repaymenting"]["current_money"]+$user_result["td_year_repaymenting"]["current_money"],2)?>' + "</td></tr></table>";
    modcont.push(modcont5);
    var idauth, mobileauth, mailauth, pwdauth, idtxt, mobiletxt, mailtxt, pwdtxt;
    if (accData.SecurityResponse.IdValidate == 0) {
        idauth = "mod_auth_g";
        idtxt = "实名认证 <a href='/user/security'>去设置</a>"
    } else {
        if (accData.SecurityResponse.IdValidate == 1 && accData.SecurityStatusId < 100) {
            idauth = "mod_auth_o";
            idtxt = "已实名认证"
        } else {
            if (accData.SecurityResponse.IdValidate == 1 && accData.SecurityStatusId == 100) {
                idauth = "mod_auth_r";
                idtxt = "已实名认证"
            }
        }
    } if (accData.SecurityResponse.PhoneValidate == 0) {
        mobileauth = "mod_auth_g";
        mobiletxt = "绑定手机 <a href='/user/security'>去设置</a>"
    } else {
        if (accData.SecurityResponse.PhoneValidate == 1 && accData.SecurityStatusId < 100) {
            mobileauth = "mod_auth_o";
            mobiletxt = "已绑定手机"
        } else {
            if (accData.SecurityResponse.PhoneValidate == 1 && accData.SecurityStatusId == 100) {
                mobileauth = "mod_auth_r";
                mobiletxt = "已绑定手机"
            }
        }
    } if (accData.SecurityResponse.EmailValidate == 0) {
        mailauth = "mod_auth_g";
        mailtxt = "绑定邮箱 <a href='/user/security'>去设置</a>"
    } else {
        if (accData.SecurityResponse.EmailValidate == 1 && accData.SecurityStatusId < 100) {
            mailauth = "mod_auth_o";
            mailtxt = "已绑定邮箱"
        } else {
            if (accData.SecurityResponse.EmailValidate == 1 && accData.SecurityStatusId == 100) {
                mailauth = "mod_auth_r";
                mailtxt = "已绑定邮箱"
            }
        }
    } if (accData.SecurityResponse.PwdValidate == 0) {
        pwdauth = "mod_auth_g";
        pwdtxt = "登录密码 <a href='/user/security'>去设置</a>"
    } else {
        if (accData.SecurityResponse.PwdValidate == 1 && accData.SecurityStatusId < 100) {
            pwdauth = "mod_auth_o";
            pwdtxt = "已设置密码"
        } else {
            if (accData.SecurityResponse.PwdValidate == 1 && accData.SecurityStatusId == 100) {
                pwdauth = "mod_auth_r";
                pwdtxt = "已设置密码"
            }
        }
    }
    var modcont6 = "<div class='auth_topnav'><div class='mod_authnav " + idauth + " auth_user'>" + idtxt + "</div><div  class='mod_authnav " + mobileauth + " auth_mobile'>" + mobiletxt + "</div><div  class='mod_authnav " + pwdauth + " auth_pwd'>" + pwdtxt + "</div><div  class='mod_authnav " + mailauth + " auth_msg'>" + mailtxt + "</div></div>";
    modcont.push(modcont6);

    this.loadmod = function(moddata) {
        var moddata;
        $("#modnav").html("");
		var moddata={ "data": [{ "mod": "0", "stuats":"1" ,"idx":"0","tit":"理财统计"},{ "mod": "1", "stuats":"1","idx":"1","tit":"我的借款"},{ "mod": "2", "stuats":"1","idx":"2","tit":"投标概况"},{ "mod": "3", "stuats":"1","idx":"4","tit":"认证信息"},{ "mod": "4", "stuats":"1","idx":"4","tit":"待回款"},{ "mod": "5", "stuats":"1","idx":"5","tit":"安全信息"}]};
        var listdata = moddata.data;
        listdata.sort(function(a, b) {
            return a.idx - b.idx
        });
        listdata.forEach(function(i) {
            var html;
            var icon;
            var modurl;
            switch (Number(i.mod)) {
                case 0:
                    icon = "icon_barchart";
                    modurl = "href = '<?php echo url_for("account/lend")?>'";
                    break;
                case 1:
                    icon = "icon_user";
                    modurl = "href = '<?php echo url_for('account/myloan')?>'";
                    break;
                case 2:
                    icon = "icon_cakechart";
                    modurl = "href = '<?php echo url_for('account/backlend')?>'";
                    break;
                case 3:
                    icon = "icon_bookt";
                    modurl = "";
                    break;
                case 4:
                    icon = "icon_dhk";
                    modurl = "href = '<?php echo url_for('account/await')?>'";
                    break;
                case 5:
                    icon = "icon_lock";
                    modurl = "href = '<?php echo url_for('user/security')?>'";
                    break
            }
            if (i.stuats != "0") {
                if (i.idx % 2) {
                    html = "<li><div id='mod" + i.mod + "' class='mod' idx=" + i.idx + '><div class="panel panel-primary"> <div class="panel-heading"><span class="icon20_g ' + icon + ' ft-l"></span><h3 class="panel-title ft-l"><a ' + modurl + ">" + i.tit + '</a></h3><a href="javascript:void(0)" class="close"></a></div><div class="panel-body">' + modcont[i.mod] + "</div></div></div></li>"
                } else {
                    html = "<li><div id='mod" + i.mod + "' class='mod' idx=" + i.idx + '><div class="panel panel-primary"> <div class="panel-heading"><span class="icon20_g ' + icon + ' ft-l"></span><h3 class="panel-title ft-l"><a ' + modurl + ">" + i.tit + '</a></h3><a href="javascript:void(0)" class="close"></a></div><div class="panel-body">' + modcont[i.mod] + "</div></div></div></li>"
                }
                $("#modnav").append(html);
                $("a[mod=" + (Number(i.mod) + 1) + "]").css("color", "#009edf").find("i").addClass("icon20_b").removeClass("icon20_g")
            }
        });
        this.closeModItem()
    };
    this.add = function(i) {
        if ($("#mod" + eval("(" + $.cookie("mod") + ")").data[i - 1].mod).length < 1) {
            moddata = eval("(" + $.cookie("mod") + ")");
            moddata.data[i - 1].stuats = "1";
            this.loadmod(moddata);
            moddata = JSON.stringify(moddata);
            $.cookie("mod", moddata)
        }
    };
    this.closeModItem = function() {
        $("#modnav").find("a[class='close']").each(function() {
            $(this).on("click", function() {
                moddata = eval("(" + $.cookie("mod") + ")");
                moddata.data[Number($(this).parent().parent().parent("div[class='mod']").attr("id").split("d")[1])].stuats = "0";
                moddata = JSON.stringify(moddata);
                $.cookie("mod", moddata);
                var n = $(this).parent().parent().parent("div[class='mod']").attr("id").split("d")[1];
                $("a[mod=" + (Number(n) + 1) + "]").css("color", "#555").find("i").addClass("icon20_g").removeClass("icon20_b");
                $(this).parent().parent().parent("div[class='mod']").fadeOut(500, function() {
                    $(this).remove()
                })
            })
        })
    }
};


</script>